package it.webrules.deploymanager.webapp.service;

import it.webrules.deploymanager.core.Main;
import it.webrules.deploymanager.core.config.Command;
import it.webrules.deploymanager.core.config.ConfigurationException;
import it.webrules.deploymanager.core.config.ConfigurationService;
import it.webrules.deploymanager.core.dy.build.CIException;
import it.webrules.deploymanager.core.dy.deploy.AvailableServerException;
import it.webrules.deploymanager.core.dy.deploy.DeployException;
import it.webrules.deploymanager.core.dy.repos.RepositoryException;
import it.webrules.deploymanager.core.st.scm.SCMException;

import java.io.File;
import java.io.FileNotFoundException;

import javax.inject.Singleton;

@Singleton
public class CoreService extends BaseService {

	private Main core;

	public CoreService() {
		core = new Main();
	}

	public Object getListDeployableRelease(File path) throws ConfigurationException, CIException, RepositoryException,
			AvailableServerException, DeployException, SCMException, FileNotFoundException {

		ConfigurationService configurationService = new ConfigurationService();
		configurationService.setCommand(Command.ListDeployableRelease);
		configurationService.configWith(path);

		return core.run(configurationService);

	}

}
